<?php
/**
 * Contact controller for the default module
 *
 * @category    IPB_CMS
 * @package     Application_Module_Default
 * @subpackage  Controller
 * @copyright   Copyright (c) 2009 IPB CMS <http://ipb-cms.googlecode.com/>
 * @license     http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
 * @author      Henrique Moody <henriquemoody@gmail.com>
 */
class ContactController extends Zend_Controller_Action
{
    /**
     * Index action
     *
     * @return void
     */
    public function indexAction()
    {
        $form = new Form_Contact;
        $request = $this->getRequest();
        if ($request->isPost()) {
            if ($form->isValid($request->getPost())) {
                // TODO Send a email with the form data for the site owner
                $values = $form->getValues();
                $this->_helper->redirector('thank-you');
            }
        }
        $this->view->title = 'Contact form';
        $this->view->form  = $form;
        return $this->renderScript('common/form.phtml');
    }

    /**
     * Shows a "Thak You" message for the user
     *
     * This action muste be called before the form submission
     *
     * @return void
     */
    public function thankYouAction()
    {
        $this->view->title = 'Thank You!!';
        $this->view->message = 'Your message was send with success';
    }
}
